package com.mr.model;

import java.sql.Timestamp;

import javax.validation.constraints.NotNull;

import org.apache.commons.lang.StringUtils;
import org.hibernate.validator.constraints.NotEmpty;

import com.mr.util.DateUtil;
public class Goods extends BaseObject{
	private static final long serialVersionUID = 8982944535273863279L;
	private Long id;
	private Long relatedid;
	private Long parentid;
	@NotEmpty(message="名称不能为空！")
	private String name;
	private String logo;
	private Integer remain;	
	@NotNull(message="数量不能为空！")
	private Integer quantity;
	@NotNull(message="请输入产品价格！")
	private Integer price;
	private String unit;
	private String capacity;
	private String efficacy;
	private String usemethod;
	private String status;
	private String content;
	private Timestamp addtime;
	
	private Long typeid;			//商品类型
	private String sno;				//货号
	private String dime;			//规格
	private Double shopPrice;		//零售价	 
	private Double proxyPrice;		//供应价
	private Double specialPrice;	//特价
	private String pudi;			//铺底
	private Integer totalPack;		//箱数
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Goods(){
		this.addtime = DateUtil.getCurTimestamp();
		this.status = Status.Y;
		this.remain = this.quantity;
	}
	public Goods(Long relateid, Long parentid, String name, Integer price, String unit, Integer quantity){
		this();
		this.relatedid = relateid;
		this.parentid = parentid;
		this.name = name;
		this.price = price;
		this.unit = unit;
		this.quantity = quantity;
		this.remain = this.quantity;
	}
	public Goods(Long relatedid, Integer quantity, Goods goods) {
		this();
		this.logo = goods.getLogo();
		this.relatedid = relatedid;
		this.parentid = goods.getId();
		this.name = goods.getName();
		this.price = goods.getPrice();
		this.unit = goods.getUnit();
		this.quantity = quantity;
		this.remain = this.quantity;
		this.capacity = goods.getCapacity();
		this.efficacy = goods.getEfficacy();
		this.usemethod = goods.getUsemethod();
		
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public Long getRelatedid() {
		return relatedid;
	}
	public void setRelatedid(Long relatedid) {
		this.relatedid = relatedid;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public Timestamp getAddtime() {
		return addtime;
	}
	public void setAddtime(Timestamp addtime) {
		this.addtime = addtime;
	}
	public Integer getRemain() {
		return remain;
	}
	public void setRemain(Integer remain) {
		this.remain = remain;
	}
	public Integer getQuantity() {
		return quantity;
	}
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (!(o instanceof Goods))
			return false;

		final Goods temp = (Goods) o;

		return !(this.getId() != null ? !(this.getId().equals(temp.getId()))
				: (temp.getId() != null));

	}

	public int hashCode() {
		return (this.getId() != null ? this.getId().hashCode() : 0);
	}
	public Integer getPrice() {
		return price;
	}
	public void setPrice(Integer price) {
		this.price = price;
	}
	public String getUnit() {
		return unit;
	}
	public void setUnit(String unit) {
		this.unit = unit;
	}
	public Long getParentid() {
		return parentid;
	}
	public void setParentid(Long parentid) {
		this.parentid = parentid;
	}
	public void buyGoods(Integer quantity){
		this.remain = this.remain-quantity;
	}
	public String getLogo() {
		return logo;
	}
	public void setLogo(String logo) {
		this.logo = logo;
	}
	public String getSlogo(){
		if(StringUtils.isBlank(logo)) return "images/default.gif";
		return this.logo;
	}
	public String getCapacity() {
		return capacity;
	}
	public void setCapacity(String capacity) {
		this.capacity = capacity;
	}
	public String getEfficacy() {
		return efficacy;
	}
	public void setEfficacy(String efficacy) {
		this.efficacy = efficacy;
	}
	public String getUsemethod() {
		return usemethod;
	}
	public void setUsemethod(String usemethod) {
		this.usemethod = usemethod;
	}
	public Integer getSellNum() {
		return this.quantity-this.remain;
	}
	public String getSno() {
		return sno;
	}
	public void setSno(String sno) {
		this.sno = sno;
	}
	public String getDime() {
		return dime;
	}
	public void setDime(String dime) {
		this.dime = dime;
	}
	public Double getShopPrice() {
		return shopPrice;
	}
	public void setShopPrice(Double shopPrice) {
		this.shopPrice = shopPrice;
	}
	public Double getProxyPrice() {
		return proxyPrice;
	}
	public void setProxyPrice(Double proxyPrice) {
		this.proxyPrice = proxyPrice;
	}
	public Double getSpecialPrice() {
		return specialPrice;
	}
	public void setSpecialPrice(Double specialPrice) {
		this.specialPrice = specialPrice;
	}
	public String getPudi() {
		return pudi;
	}
	public void setPudi(String pudi) {
		this.pudi = pudi;
	}
	public Integer getTotalPack() {
		return totalPack;
	}
	public void setTotalPack(Integer totalPack) {
		this.totalPack = totalPack;
	}
	public Long getTypeid() {
		return typeid;
	}
	public void setTypeid(Long typeid) {
		this.typeid = typeid;
	}
}